﻿using System.Runtime.Serialization;

namespace ED.Common.BaseModel
{
    /// <summary>
    /// 统一请求基类
    /// </summary>

    [DataContract]
    public class BaseGrpcReq
    {

    }
    /// <summary>
    /// 分页请求基类
    /// </summary>
    [DataContract]
    public class BaseGrpcReqPage : BaseGrpcReq
    {
        /// <summary>
        /// 默认页码
        /// </summary> 
        private int pageIndex = 1;

        /// <summary>
        /// 默认页数
        /// </summary>
        private int pageSize = 10;

        /// <summary>
        /// 当前页码
        /// </summary>
        [DataMember(Order =1)]
        public int PageIndex
        {
            set
            {
                if (value <= 0)
                {
                    value = 1;
                }
                pageIndex = value;
            }
            get { return pageIndex; }
        }
        /// <summary>
        /// 页码条数
        /// </summary>
        [DataMember(Order = 2)]
        public int PageSize
        {
            set
            {
                if (value <= 0)
                {
                    value = 10;
                }
                pageSize = value;
            }
            get
            {
                return pageSize;
            }
        }
    }
    /// <summary>
    /// 表示分页数据模型
    /// </summary>
    /// <typeparam name="T">数据模型</typeparam>
    /// <example>
    /// <code>
    /// public ResponseOutput&lt;PageOut&lt;Model>> QueryPersons()
    /// {
    ///       //...
    ///       return ResponseOutput.Ok&lt;PageOut&lt;Model>>(new PageOut&lt;Model>()
    ///       {
    ///           TotalCount = 125,
    ///           List = new List&lt;Model>()
    ///       });
    /// }
    /// </code>
    /// </example>
    [DataContract]
    public class GrpcPageOut<T>
    {
        /// <summary>
        /// 总数
        /// </summary>
        [DataMember(Order = 1)]
        public long TotalCount { get; set; }

        /// <summary>
        /// 当前页数据
        /// </summary>
        [DataMember(Order = 2)]
        public IList<T> List { get; set; }
    }
}
